package com.hhkj.admin.conf.common.validator.commission;

import cn.hutool.extra.spring.SpringUtil;
import com.hhkj.admin.conf.model.extend.CommissionRate;
import com.hhkj.admin.conf.model.req.CommissionRateReq;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class CommissionRateValidator implements ConstraintValidator<ValidateCommissionRate, CommissionRateReq> {

    private CommissionRateValidatorAssembler commissionRateValidatorAssembler = SpringUtil.getApplicationContext().getBean(CommissionRateValidatorAssembler.class);

    @Override
    public boolean isValid(CommissionRateReq commissionRateReq, ConstraintValidatorContext constraintValidatorContext) {
        constraintValidatorContext.disableDefaultConstraintViolation();
        return commissionRateValidatorAssembler.getHead().validateNext(commissionRateReq, constraintValidatorContext);
    }
}
